// packageE/membertop/membertop.js
Component({
  properties: {
    datas: {
      type: null,
    },
    component_id: {
      type: null,
    },
    member_item: {
      type: null,
    },
    isMemberGrade: {
      type: null,
    },
    validity_value: {
      type: null,
    },
  },
  // 私有数据，可用于模板渲染
  data: {
    emptyImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png",
    nickname: "昵称",
    uid: "666",
    inviteCode: "888888",
    level_name: "普通会员",
  },
  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached() {},
    moved() {},
    detached() {},
  },

  // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
  attached() {},
  // 此处attached的声明会被lifetimes字段中的声明覆盖
  ready() {},

  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show() {},
    hide() {},
    resize() {},
  },
  methods: {
    TapEdit(){
      this.triggerEvent('TapEditChild')
    },
    copybtn(e) {
      let inviteCode = e.target.dataset.num;
      wx.setClipboardData({
        data: inviteCode ? inviteCode : "",
        success(res) {
          wx.showToast({
            icon: "none",
            title: "复制成功",
            duration: 1000,
          });
        },
      });
    },
    //跳转至会员权益
    gotoMemberGrade() {
      //MemberGradeList
      if (this.data.isMemberGrade && this.data.datas.grade_type == "1") {
        wx.navigateTo({
          url: "/packageB/member/MemberGradeList/MemberGradeList",
        });
      } else if (this.data.datas.grade_type == "2") {
        if (!this.data.datas.levelname && !this.data.datas.isagent) {
          wx.navigateTo({
            url: "/packageA/member/extension/ExtensionApply/ExtensionApply",
          });
        } else {
          wx.navigateTo({
            url: "/packageB/member/income/teamAgentCenter/teamAgentCenter",
          });
        }
      } else if (this.data.datas.grade_type == "3") {
        if (!this.data.datas.levelname && !this.data.datas.isagent) {
          wx.navigateTo({
            url: "/packageA/member/extension/ExtensionApply/ExtensionApply",
          });
        } else {
          wx.navigateTo({
            url: "/packageA/member/distribution/distribution",
          });
        }
      }
    },
  },
});
